﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Vara_Data_Layer.Vara_Data_Asset;

namespace AssetTrackingModals.User_Controls.Asset_Module.Tabs
{
    public partial class Tab_4_Owner_Location : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void Load_Interface(Vara_Data_IAsset AssetInformationToLoad)
        {
            if (AssetInformationToLoad.ID == 0)
            {
                TextBox_Owner.Text = string.Empty;
            }
            else
            {
                TextBox_Owner.Text = AssetInformationToLoad.Owner;
                if (AssetInformationToLoad.Location != null)
                    //TextBoxLocation.Text = AssetInformationToLoad.Location.Site.Name + " - " + AssetInformationToLoad.Location.Description + " (" + AssetInformationToLoad.Location.Name + ")";
                    if (AssetInformationToLoad.Holder != null)
                        TextBox_Holder.Text = AssetInformationToLoad.Holder.FirstName + " " + AssetInformationToLoad.Holder.LastName;
            }
        }

        protected void ImageButtonHolder_Click(object sender, EventArgs e)
        {
            Modal_SearchHolder1.Show();
        }
        protected void Modal_SearchHolder1_PersonSelected(object sender, User_Controls_Modal_SearchHolder.PersonSelectionArgs e)
        {
            TextBox_Holder.Text = e.PersonName;
        }

        protected void ImageButtonOwner_Click(object sender, ImageClickEventArgs e)
        {
            Modal_SearchDepartment1.Show();
        }
        protected void Modal_SearchDepartment1_DepartmentSelected(object sender, User_Controls_Modal_SearchDepartment.DepartmentSelectionArgs e)
        {
            TextBox_Owner.Text = e.DepartmentName;
        }

        protected void ImageButtonLocation_Click(object sender, ImageClickEventArgs e)
        {
            Modal_SearchLocation1.Show();
        }
        protected void Modal_SearchLocation1_LocationSelected(object sender, User_Controls_Modal_SearchLocation.LocationSelectionArgs e)
        {
            TextBoxLocation.Text = e.Location;
        }
    }
}